import 'element-plus/dist/index.css'
import './assets/main.css'
import 'element-plus/theme-chalk/dark/css-vars.css'

import { type App as VueApp, createApp } from 'vue'
import * as dayjs from 'dayjs'
import 'dayjs/locale/zh-cn' // 导入本地化语言

import App from './App.vue'
import router from './router'

import ElementPlus from 'element-plus'
import locale from 'element-plus/es/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

// 引入组件库的少量全局样式变量
import 'tdesign-vue-next/es/style/index.css';


import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
const app = createApp(App)

function useVXETable(app: VueApp) {
  app.use(VXETable)
}

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
app.use(router)
app.use(ElementPlus, {
  zIndex: 3000,
  size: 'default',
  locale: locale
})
// 设置全局错误处理函数
app.config.errorHandler = (err, instance, info) => {
  console.error('全局错误捕获：', err)
  console.error('出错的组件实例：', instance)
  console.error('错误信息：', info)
  // 可以在这里发送错误信息到后端监控系统
}
app.use(useVXETable)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
dayjs.locale('zh-cn') // 使用本地化语言
app.mount('#app')


// import { createApp } from 'vue';
// import TDesign from 'tdesign-vue-next';
// import App from './app.vue';

// // 引入组件库的少量全局样式变量
// import 'tdesign-vue-next/es/style/index.css';

// const app = createApp(App);
// app.use(TDesign);

// 按需引入使用
// import { createApp } from 'vue';
// import { Button as TButton } from 'tdesign-vue-next';
// import App from './app.vue';

// // 引入组件库的少量全局样式变量
// import 'tdesign-vue-next/es/style/index.css';

// const app = createApp(App);
// app.use(TButton);